package abstractfactory.dao;

import abstractfactory.service.DepartmentService;
import abstractfactory.service.UserService;

public class DataAccess {
    private static final String PACKAGE_NAME = "abstractfactory.pojo";
    private static final String DB = "SqlServer";

    public static UserService createUser() throws ClassNotFoundException, InstantiationException, IllegalAccessException {
        String className = PACKAGE_NAME + "." + DB + "User";
        return (UserService) Class.forName(className).newInstance();
    }

    public static DepartmentService createService() throws ClassNotFoundException, InstantiationException, IllegalAccessException {
        String className = PACKAGE_NAME + "." + DB + "Department";
        return (DepartmentService) Class.forName(className).newInstance();
    }

}
